{% extends "base.html" %}
{% block title %}Результаты игры{% endblock %}

{% block contentheader %}Результаты: игра "{{game_type}}"{% endblock %}
{% block content %}

<script>
function view_f(s)
{
    // alert(s);
    var ob = document.getElementById(s);
    if (ob.style.display == 'none')
    {
        ob.style.display='block';
    }
    else
    {
        ob.style.display='none';
    }
}
</script>


{% for GAME in result %}
    <a href="#{{GAME["game_number"]}}"> Игра #{{GAME["game_number"]}} </a> <br>
{% endfor %}

<br> <br>



{% if wrong_pin %}
<h1> Неверный pin-код </h1>
{% endif %}
{% for GAME in result %}

<a name="{{GAME["game_number"]}}">

<h1> Игра #{{GAME["game_number"]}} </h1>

{% if GAME["admin"] %}
<strong> Неиспользованные слова: </strong>
{% for word in GAME["unused_words"] %}
{{word.text}},
{% endfor %}
{{GAME["last_unused_word"].text}} <br> <br>
<a href="delete_statistics?id={{GAME["key"]}}">Удалить из статистики</a>
{% endif %}
<br/>
{% if GAME["paired"] %}
    <a>Время игры: {{GAME["game_time"]}}</a>
    <table border>
    <tr> <td> <strong> Игрок </strong> </td> <td> <strong> Объяснил </strong> </td> <td> <strong> Угадал </strong> </td> <td> <strong> Всего </strong> </td> </tr>
    {% for pair in GAME["pairs"] %}
        <tr> <td> {{pair.player_1}} </td> <td> {{pair.first_explained}} <br/>
        <!--- List of explained words -->
        <button onClick='view_f("{{pair.pair_id}}1")'> Слова </button>
        <div id="{{pair.pair_id}}1" style="display:none">
        {% for word in pair.first_explained_words %}
            {{word}} <br>
        {% endfor %}
    </div>
    <!--- // List of explained words -->
    </td> <td> {{pair.first_guessed}} </td> <td rowspan=2> {{pair.sum}} </td> </tr>
    <tr> <td> {{pair.player_2}} </td> <td> {{pair.first_guessed}} <br/>
    <!--- List of explained words -->
    <button onClick='view_f("{{pair.pair_id}}2")'> Слова </button>
    <div id="{{pair.pair_id}}2" style="display:none">
    {% for word in pair.second_explained_words %}
    {{word}} <br>
    {% endfor %}
    </div>
    <!--- // List of explained words --> 
    </td> <td> {{pair.first_explained}} </td> <td rowspan=2> </td> </tr>
    {% endfor %}
    </table>
    <!---
    Формат указания игроков
    <tr> <td> Player1 </td> <td> 1 </td> <td> 3 </td> <td rowspan=2> 4 </td> </tr>
    <tr> <td> Player2 </td> <td> 3 </td> <td> 1 </td> <td> </td> </tr>
    -->

{% else %}
    <table border>
    <tr> <td> <strong> Игрок </strong> </td> <td> <strong> Объяснил </strong> </td> <td> <strong> Угадал </strong> </td> <td> <strong> Всего </strong> </td> </tr>
    {% for player in GAME["singles"] %}

    <tr> <td> {{player}} </td> <td> {{singles[player].explained}} <br>
    <!--- List of explained words -->

    <button onClick='view_f("{{singles[player].id}}1")'> Слова </button>
    <div id="{{singles[player].id}}1" style="display:none">
    {% for word in singles[player].explained_words %}
    {{word}} <br>
    {% endfor %}
    </div>

    <!--- // List of explained words -->
    </td> <td> {{singles[player].guessed}} <br>
    <!--- List of guessed words -->

    <button onClick='view_f("{{singles[player].id}}2")'> Слова </button>
    <div id="{{singles[player].id}}2" style="display:none">
    {% for word in singles[player].guessed_words %}
    {{word}} <br> 
    {% endfor %}
    </div>

    <!--- // List of guessed words -->
    </td> <td> {{singles[player].explained + singles[player].guessed}} </td> </tr>

    {% endfor %}

    </table>
{% endif %}



<br> <br> <br> <br>

{% endfor %}

{% endblock %}
